package org.lsms.servlet;

/**
 * invoked when chair comment on a certain paper
 * @author ZhanXueliang
 * 2010.9.19
 */

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lsms.dao.impl.DaoImpl;

public class chair_comment extends HttpServlet {

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			
			int paper_id = Integer.parseInt(request.getParameter("paper_id"));
			String chair_to_author = request.getParameter("chair_to_author");
			int pass = Integer.parseInt(request.getParameter("pass"));
			
			DaoImpl impl = new DaoImpl();
			if(impl.chair_comment(paper_id, chair_to_author) && impl.update_paper_status(pass, paper_id)){
				String info = "Decision submit succeed!";
				response.sendRedirect("chair/chair_show_info.jsp?chair_info="+info);
				return;
			}else{
				String info = "Problem occurs when submit the decison.Please contact the  " +
						"administrator!";
				response.sendRedirect("chair/chair_show_info.jsp?chair_info="+info);
			}
	}

	
	public void init() throws ServletException {

	}

}
